<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        #box{
            width:100%;
            height: 300px;
            background: #cae;
        }
    </style>
</head>
<body>
    
    <div id="box">

    </div>

    <script>
        //获取元素
        let box = document.querySelector("#box");

        //绑定事件
        box.ontouchstart = function(){
            console.log('你触摸了我');
            this.start = Date.now();
        }

        //
        box.addEventListener("touchmove", function(){
            console.log('手指滑呀滑');
        })

        //
        box.addEventListener('touchend', function(){
            console.log('手指离开了');
        })

        //
        box.addEventListener('touchcancel', function(){
            console.log('触摸被打断了');
        })

        box.addEventListener('click', function(){
            console.log('我被点击了');
            this.end = Date.now();
            console.log(this.end - this.start);
        })

        // setTimeout(() => {
        //     alert('主人, 那家伙又来电话啦!!');
        // }, 3000)
    </script>
</body>
</html>